/*
 * Copyright (c) 2011 CCXE(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCXE(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCXE(China) Co.,Ltd.
 *
 * Author: zhaoshujin
 * Date: 2011-10-28 下午06:25:33
 */
package com.test;

/**
 * @author zhaoshujin
 * 
 */
public class Swap {
	public static void main(String[] args) {
		// java参数传递只有值调用，没有引用调用。
		Student s1 = new Student(1, "dai");
		Student s2 = new Student(2, "kai");
		s1.print();
		s2.print();

		swap(s1, s2);// 如果是引用调用的话s1与s2就应该是交换了。
		s1.print();
		s2.print();

		changeName(s1);
		s1.print();
	}

	public static void swap(Student s1, Student s2) {
		Student temp = s1;
		s1 = s2;
		s2 = temp;
	}

	public static void changeName(Student s) {
		s.setName("New Name");
	}
}

class Student {
	private int number;
	private String name;

	public Student(int number, String name) {
		this.number = number;
		this.name = name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void print() {
		System.out.println("number:" + number + "  name:" + name);
	}
}
